<template>
  <div class="met-product-body" >
    <div class="met-product-list">
      <ul class="ul">
        <li v-for="item in product_list" :key="item.id" class="li" :class="listStyle==='window'?'window':''">
          <div class="media" v-if="item.imgurl">
            <div class="img">
              <img mode="widthFix" style="width:100%;" :src="item.imgurl" alt="">
            </div>
            <div class="content">
              <h4 class="title">
                <a @click="handleLink(item)" :style="{color:app_tabBar.config.firstcolor}">
                  {{item.title}}
                </a>
              </h4>
              <p class="desc" :style="{color:app_tabBar.config.secondcolor}">
                {{item.description}}
              </p>
            </div>
          </div>
          <div class="media" v-else>
            <div class="content">
              <h4>
                <a @click="handleLink(item)" :style="{color:app_tabBar.config.firstcolor}">
                  {{item.title}}
                </a>
              </h4>
              <p class="desc" :style="{color:app_tabBar.config.secondcolor}">
                {{item.description}}
              </p>
            </div>
          </div>
        </li>
      </ul>      
      <div v-if="product_list.length===0" :style="'color:red'">
        数据不能为空
      </div>
    </div>
  </div>
</template>
<script>
import { mapGetters } from 'vuex'
import { navigateToViewPage } from '@/utils/index'
export default {
  props: {
    listStyle: String
  },
  computed: {
      ...mapGetters(['app_tabBar','product_list', 'app_viewHeight'])
  },
  data() {
    return {
      data: {}
    }
  },
  methods: {
    handleLink(item) {
      navigateToViewPage('product', item, this)
    }
  }
}
</script>
<style lang="scss" scoped>
.met-product-body {
  padding: 15px;
  .met-product-list {
    .ul {
      display: flex;
      flex-wrap: wrap;
    }
    .li {
      width: 50%;
      padding-right: 15px;
      box-sizing: border-box;
      &.window {
        width: 100%;
      }
    }
    .media {
      padding-bottom: 15px;
      margin-bottom: 15px;
      border-bottom: 1px solid #dcdcdc;
      position: relative;
      .img {
        width: 100%;
      }
      .content {
        flex: 1;
        .title {
          font-size: 16px;
          margin-bottom: 10px;
          color: #444;
        }
        .desc {
          color: #848484;
          font-size: 13px;
          margin-bottom: 10px;
          overflow: hidden;
          height: 40px;
          font-weight: 300;
        }
      }
    }
  }
}
</style>